#include<iostream>
#include<stdlib.h>
using namespace std;

int t ,n , m , a , b ,len ,start ,end,vertex;
int dist[101][101],path[101][101],route[101],branch[101];
int h , i , j  , k , l ,p ,q;

void Root(int p,int q)
{
    if (path[p][q]>0)
    {
        Root(p,path[p][q]);
        Root(path[p][q],q);
    }
    else
    {
        route[k]=q;
        k++;
    }
}

int valid(int a,int b,int c)  
{  
    return a+b>c && a+c>b && b+c>a;  
}  

int partion(int * a,int p,int q)  
{  
    int i,j;  
    for(i = p-1,j = p;j<q;++j)  
    {  
        if(a[j] < a[q] && a[++i]> a[q])  
            swap( a[i],a[j] );  
    }  
    swap(a[i+1],a[q]);  
    return i+1;  
}  

int subtri(int * a,int p,int q)  
{  
    int mid;   
    if(q-p+1 < 3)return 0;  
        mid = partion(a,p,q);  
    if(subtri(a,p,mid-1)||subtri(a,mid+1,q))return 1;  
    else  
    {  
        int l,r;  
        for(l = p;l<mid;l++)  
            for(r = mid+1;r <= q;++r)  
            {  
                if(valid(a[r],a[l],a[mid]))return 1;  
            }  
        for(l = p;l<mid;l++)  
            for(r = p;r<mid;r++)  
            {  
                if(r != l && valid(a[r],a[l],a[mid]))return 1;  
            }  
        for(l = mid+1;l<=q;l++)  
            for(r = mid+1;r<=1;r++)  
            {  
                if(r != l && valid(a[r],a[l],a[mid]))return 1;  
            }  
    }  
    return 0;  
}  

int main()
{
    cin>>t;
    for( i = 0 ; i < t ; i++ )    
    {
        memset(dist , 0 , sizeof(dist) );
        memset(path , 0 , sizeof(path) );
        memset(route, 0 , sizeof(route));
        memset(branch,0 , sizeof(branch));
        
        cin>>vertex;
        for( j = 1 ; j <= vertex-1 ; j++ )//n-1 edges 
        {
            cin>>a>>b>>len;     
            dist[a][b] = len;
            dist[b][a] = len;
        }
        /* calculate the shortest path using floyd */
        for( k = 1 ; k <= vertex ; k++ )
          for( p = 1 ; p <= vertex ; p++ )
          { 
              if (dist[p][k]>0)
              for( q = 1 ; q <= vertex ; q++ )
              {
                  if (dist[k][q]>0)
                  {
                      if (((dist[p][q]>dist[p][k]+dist[k][q])||(dist[p][q]==0))&&(p!=q))
                      {
                          dist[p][q]=dist[p][k]+dist[k][q];
                          path[p][q]=k;
                      }
                  }//if
          }//for
        }//for 
        
        cout<<"Case #"<<i+1<<":"<<endl;
        /* find the path from point a to  point b */
        cin>>m;
        for( j = 0 ; j < m ; j++ )
        {
            cin>>start>>end;     
            k = 2 ;
            Root(start,end);
            route[1] = start;
            for( h = 1; h<k-1 ; h++ )//there are k-1 nodes : route[1]...route[n-1]
            {
              cout<<route[h]<<"-->";
              branch[h] = dist[ route[h] ][ route[h+1] ];   
            }
            cout<<route[k-1]<<endl;
                
            for( h = 1; h<k-1 ; h++ )
                cout<<branch[h]<<"--";
                cout<<endl;
            /* calculate that what the trees can form triangle */
            cout<<"k-2 : " <<k-2<<endl;
            //int a[] = {32,60,45};
            if( subtri(branch,1,k-2) ) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;    
        }
    }//for 
    
    system("pause");
    return 0 ;
} 
